<?php

namespace Drupal\shushengyuan\Schemas;

use Drupal\shusy_plant_grass_comments\Entity\ShusyPlantGrassComments;

/**
 * @OA\Schema(
 *   schema="PlantGrassCommentsItem",
 *   type="object",
 *   description="PlantGrassCommentsItem"
 * )
 */
class PlantGrassCommentsItem extends AbstractBaseModel {

  protected function getEntityType() {
    return 'shusy_plant_grass_comments';
  }

  protected function setValue() {
    if($this->entity instanceof ShusyPlantGrassComments){
      $value = [
        //ID
        /**
         * @OA\Property(
         *   property="id",
         *   type="integer",
         *   description="ID",
         * ),
         */
        'id' => (int) $this->entity_id,
        /**
         * @OA\Property(
         *   property="user",
         *   ref="#/components/schemas/User",
         *   description="评论用户",
         * ),
         */
        'user' => User::get($this->entity->uid),
        //时间 Y-m-d
        /**
         * @OA\Property(
         *   property="created",
         *   type="string",
         *   description="时间",
         * ),
         */
        'created' => (string) $this->formatDate($this->entity->created, 'Y-m-d'),
        //评论内容
        /**
         * @OA\Property(
         *   property="info",
         *   type="string",
         *   description="评论内容",
         * ),
         */
        'info' => (string) $this->entity->content,
      ];
      $this->merge($value);
    }
  }

}
